# -*- coding: utf-8 -*-
"""
@ auth : carl_DJ
@ time : 2020-9-23
"""

from locust import HttpUser, TaskSet, task, constant,constant_pacing,between

'''
执行顺序：
Locust setup → TaskSet setup → TaskSet on_start → 
TaskSet tasks → TaskSet on_stop → TaskSet teardown → 
Locust teardown
'''


class Stay(TaskSet):
    @task(3)
    def readBook(self):
        print('I am reading a book.')

    @task(7)
    def listenMusic(self):
        print('I am listening to music.')

    @task(1)
    def logOut(self):
        self.interrupt()


class UserTask(TaskSet):
    # tasks = {Stay: 2}
    tasks = [Stay]

    @task(1)
    def leave(self):
        self.client.get('/s?wd=python')
        print('I don not like this page.')


class WebsitUser(HttpUser):
    def setup(self):
        print('locust setup')

    def teardown(self):
        print('locust teardown')

    host = 'http://www.baidu.com'
    # task_set = task(UserTask)
    tasks = [UserTask]
    wait_time = constant(1)
    # min_wait = 100
    # max_wait = 5000


if __name__ == '__main__':
    pass
